function main(defaultParams) {

    Vue.nextTick(res => {
        let self = this;
        // 在表单部件中的数据保存成功时刷新表格
        if (defaultParams.moduleActionType === 'form-save') {
            let human_id = defaultParams.id.value;
            let managementId = defaultParams.callbackParams.data.documentNo
            let humanUUID = defaultParams.human_uuid.value;//
            let applyApprovalReason = defaultParams.callbackParams.data['t_5a380704cc1c4f139e0c45b89a5ab317'].textarea_hn3wsr;

            // 从law_approval_config（t_4916fdfaf0174ad19ff7e4ed5355c90a）读取配置enable_flag字段
            // enable_flag=1时，启用审核流程，否则不启用
            api.EXEC_FORMULA("ENTITY_SELECT_ONE('t_4916fdfaf0174ad19ff7e4ed5355c90a',enable_flag,QUERY_EQ(id,2))").then(res => {
                if (res.result === '1') {
                    // 启用审核流程，新增辞退审核记录
                    insertApproval(humanUUID, applyApprovalReason, managementId).then(res => {
                        if (res.result) {
                            console.log('新增辞退审核记录成功');
                            self.$message.success('办理辞退申请成功！')
                            updateList(self);
                        }
                    });
                } else {

                    api.EXEC_FORMULA("UPDATE('t_2488d76f089b4f00aae44062307659fd', QUERY_EQ('id', " + human_id + "), '', ['work_status_code', 6,'work_status_name','已辞退'])").then((res) => {
                        if (res.result) {
                            console.log('更新成功');
                            updateList(self);
                        }
                    });

                }
            });
        }
    });

}


/**
 * 新增人员辞退审核纪录
 */
function insertApproval(humanUUID, applyApprovalReason, managementId) {

    return new Promise((resolve, reject) => {
        let insertApprovalSql = `INSERT('t_655b23a930504145bf2ba2f014780dc6',['human_uuid','${humanUUID}','approval_type_code',2,'approval_type_name','人员辞退','apply_approval_reason','${applyApprovalReason}','create_human_id',USER_ID(),'create_time',NOW(),'management_id','${managementId}'])`

        console.log(insertApprovalSql);

        api.EXEC_FORMULA(insertApprovalSql).then((res) => {
            resolve(res);
            console.log("新增人员辞退审核成功", res);
        });
    }).catch(err => {
        reject(err);
        console.log("新增人员辞退审核失败", err);
    });
}


function updateList(self) {
    // 获取页面列表组件
    var pageListEle = self.$$("page_widget_list_6a5nyq");
    var pageListEle1 = self.$$("page_widget_list_d85qj6");

    // 获取列表渲染页实例
    var listRenderView = pageListEle.$$getRenderElement();
    var listRenderView1 = pageListEle1.$$getRenderElement();

    // 获取当前显示的组件，表格或者卡片
    var currentListEle = listRenderView.$$getListElement();
    var currentListEle1 = listRenderView1.$$getListElement();

    // 调用刷新方法
    currentListEle.$$refreshData();
    currentListEle1.$$refreshData();
}
